package com.example.back.controller;

import com.example.back.dto.req.DeleteCheckupTypeDto;
import com.example.back.dto.resp.GetCheckTypeList;
import com.example.back.service.CheckupTypeService;
import com.example.common.entity.CheckupType;
import com.example.common.support.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @ClassName CheckupTypeController
 * @Author wengjt
 * @Date 2021/5/8 10:55
 * @Description
 **/
@RestController
@Api(tags = "体检类型管理")
@RequestMapping("/checkupType")
public class CheckupTypeController {

    @Resource
    private CheckupTypeService checkupTypeService;

    @GetMapping("/list")
    @ApiOperation(value = "多条件查询体检类型,带分页")
    public Result<GetCheckTypeList> getCheckTypeList(Integer ctId, Integer showAble, Integer pageNum, Integer pageSize) {
        return Result.success(checkupTypeService.getCheckTypeList(ctId, showAble, pageNum, pageSize));
    }

    @GetMapping("")
    @ApiOperation(value = "获取单个体检类型详情")
    public Result<CheckupType> getInfo(Long ctId) {
        return Result.success(checkupTypeService.getInfo(ctId));
    }

    @PutMapping("")
    @ApiOperation(value = "修改体检类型")
    public Result<Object> updateCheckup(@RequestBody CheckupType checkupType) {
        return Result.success(checkupTypeService.updateCheckup(checkupType));
    }

    @PostMapping("")
    @ApiOperation(value = "新增体检类型")
    public Result<Object> insertCheckup(@RequestBody CheckupType checkupType) {
        return Result.success(checkupTypeService.insertCheckup(checkupType));
    }

    @DeleteMapping("")
    @ApiOperation(value = "删除体检类型")
    public Result<Object> deleteCheckup(@RequestBody DeleteCheckupTypeDto dto) {
        return Result.success(checkupTypeService.deleteCheckup(dto.getCtId()));
    }
}
